package org.common.eureka.service.impl;

import org.common.eureka.mapper.DwCatalogMapper;
import org.common.eureka.service.IDwCatalogService;
import org.sam.commons.entity.pojo.DwCatalog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 缓存雪崩
 *
 * @author samphin
 * @since 2020-6-14 10:28:19
 */
@Service
public class DwCatalogServiceImpl implements IDwCatalogService {

    @Autowired
    private DwCatalogMapper catalogMapper;

    @Override
    @CacheEvict(value = "catalog",key = "#id")
    public int deleteByPrimaryKey(String id) {
        return catalogMapper.deleteByPrimaryKey(id);
    }

    @Override
    @CachePut(value = "catalog",key="#record.id")
    public int insertSelective(DwCatalog record) {
        return catalogMapper.insertSelective(record);
    }

    @Override
    @Cacheable(value = "catalog")
    public DwCatalog queryByPrimaryKey(String id) {
        return catalogMapper.selectByPrimaryKey(id);
    }

    @Override
    @Cacheable(value = "catalog_all")
    public List<DwCatalog> queryAll(Map<String, Object> params) {
        return catalogMapper.selectAll();
    }
}
